import { cloneDeep } from 'lodash'

module.exports = {
  data() {
    return {
      formRootInstance: {}, // 表单配置项
      formRules: {}, // 表单规则
      initModel: {}, // 初始值
      tempModel: {}, //  临时表单保存
      submitButtonOptions: {} // 提交按钮配置
    }
  },
  created() {
    this.settingFormSetting(this.formConfig)
  },
  methods: {
    settingFormSetting(config) {
      if (config) {
        const {
          initModel,
          tempModel,
          formRootInstance,
          rules,
          submitButtonOptions // 提交按钮的回调事件
        } = config
        this.formRootInstance = formRootInstance
        this.formRules = cloneDeep(rules)
        this.initModel = initModel
        this.tempModel = tempModel
        this.submitButtonOptions = submitButtonOptions
      }
    }
  }
}